package logic

import (
	"context"
	"net/http"
	"week1_zg6/common/pay"

	"week1_zg6/orderapi/internal/svc"
	"week1_zg6/orderapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CallbackLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CallbackLogic {
	return &CallbackLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CallbackLogic) Callback(writer http.ResponseWriter, request *http.Request) (resp *types.Response, err error) {
	pay.Notify(writer, request)
	return &types.Response{
		Code: http.StatusOK,
		Msg:  "支付回调成功",
		Date: nil,
	}, nil
}
